package com.lemon.smartsafety.ui.adapter.safe.data;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.lemon.smartsafety.R;
import com.lemon.smartsafety.entity.main.OptionItemVo;

import java.util.List;

import kale.adapter.CommonAdapter;
import kale.adapter.item.AdapterItem;

/**
 * 在dialog中使用的周期选择适配器
 */
public class CycleUnitAdapter extends CommonAdapter<OptionItemVo> {
    private OptionItemVo mData;
    private int          mPosition;
    private String  mOldValue        = null;
    private boolean showDownSubTitle = false;

    public CycleUnitAdapter(@Nullable List<OptionItemVo> data) {
        super(data);
    }

    @NonNull
    @Override
    public AdapterItem createItem(Object type) {
        return new CycleUnitItem();
    }

    public class CycleUnitItem implements AdapterItem<OptionItemVo> {
        private LinearLayout   ripple;
        private LinearLayout drawer;
        private TextView     itemText;
        private TextView     itemSubDownText;
        private TextView     itemSubText;
        private ImageView    imageSelect;

        @Override
        public int getLayoutResId() {
            return R.layout.item_select;
        }

        @Override
        public void bindViews(View root) {
            ripple = (LinearLayout) root.findViewById(R.id.ripple);
            itemText = (TextView) root.findViewById(R.id.itemText);
            itemSubText = (TextView) root.findViewById(R.id.itemSubText);
            itemSubDownText = (TextView) root.findViewById(R.id.itemSubDownText);
            imageSelect = (ImageView) root.findViewById(R.id.imageSelect);
            imageSelect.setVisibility(View.GONE);
        }

        @Override
        public void setViews() {

        }

        @Override
        public void handleData(OptionItemVo data, int position) {
            mData = data;
            mPosition = position;
            itemText.setText(data.getTitle());
        }
    }
}
